package com.qingcheng.controller.seckill;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.entity.PageResult;
import com.qingcheng.entity.Result;
import com.qingcheng.pojo.seckill.SeckillGoods;
import com.qingcheng.service.seckill.SeckillGoodsService;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/seckillGoods")
public class SeckillGoodsController {

    @Reference
    private SeckillGoodsService seckillGoodsService;

    @GetMapping("/findAll")
    public List<SeckillGoods> findAll(){
        return seckillGoodsService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<SeckillGoods> findPage(int page, int size){
        return seckillGoodsService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<SeckillGoods> findList(@RequestBody Map<String,Object> searchMap){
        return seckillGoodsService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<SeckillGoods> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  seckillGoodsService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public SeckillGoods findById(Long id){
        return seckillGoodsService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody SeckillGoods seckillGoods){
        seckillGoodsService.add(seckillGoods);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody SeckillGoods seckillGoods){
        seckillGoodsService.update(seckillGoods);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id){
        seckillGoodsService.delete(id);
        return new Result();
    }

}
